﻿using StateManager;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Demo_WPF
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        SManager _SManager;
        public MainWindow()
        {
            InitializeComponent();
            _SManager = new SManager(Log);
            chkboxAuto.IsChecked = _SManager.Auto;
        }

        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {

            _SManager?.Dispose();
        }

        private void chkboxAuto_Click(object sender, RoutedEventArgs e)
        {
            _SManager.Auto = chkboxAuto.IsChecked ?? false;
        }

        void Log(string node, string text, bool mode)
        {
            richTextBox1.Dispatcher.BeginInvoke(new Action(() =>
            {
                richTextBox1.AppendText($"{DateTime.Now}  {node}  {text}\r\n");
                richTextBox1.ScrollToEnd();
            }));
        }

    }
}
